section, before theme’s CSS
var $js; // the TreeViewHandler javascript
// Extend WT_Module. This title should be normalized when this module will be added officially
public function getTitle() {
return /* I18N: Name of a module */ WT_I18N::translate('Interactive tree');
}
// Extend WT_Module
public function getDescription() {
return /* I18N: Description of the “Interactive tree” module */ WT_I18N::translate('An interactive tree, showing all the ancestors and descendants of an individual.');
}
// Implement WT_Module_Tab
public function defaultTabOrder() {
return 68;
}
// Implement WT_Module_Tab
public function getTabContent() {
global $controller;
require_once WT_MODULES_DIR . $this->getName() . '/class_treeview.php';
$tv = new TreeView('tvTab');
list($html, $js) = $tv->drawViewport($controller->record, 3);
return
'' .
'' .
$html;
}
// Implement WT_Module_Tab
public function hasTabContent() {
global $SEARCH_SPIDER;
return !$SEARCH_SPIDER;
}
// Implement WT_Module_Tab
public function isGrayedOut() {
return false;
}
// Implement WT_Module_Tab
public function canLoadAjax() {
return true;
}
// Implement WT_Module_Tab
public function getPreLoadContent() {
// We cannot use jQuery("head").append(
if (document.createStyleSheet) {
document.createStyleSheet("' . $this->css() . '"); // For Internet Explorer
} else {
var newSheet=document.createElement("link");
newSheet.setAttribute("rel","stylesheet");
newSheet.setAttribute("type","text/css");
newSheet.setAttribute("href","' . $this->css() . '");
document.getElementsByTagName("head")[0].appendChild(newSheet);
}
';
}
// Extend WT_Module
// We define here actions to proceed when called, either by Ajax or not
public function modAction($mod_action) {
require_once WT_MODULES_DIR . $this->getName() . '/class_treeview.php';
switch ($mod_action) {
case 'treeview':
global $controller;
$controller = new WT_Controller_Chart();
$tv = new TreeView('tv');
ob_start();
$person = $controller->getSignificantIndividual();
list($html, $js) = $tv->drawViewport($person, 4);
$controller
->setPageTitle(WT_I18N::translate('Interactive tree of %s', $person->getFullName()))
->pageHeader()
->addExternalJavascript($this->js())
->addInlineJavascript($js)
->addInlineJavascript('
if (document.createStyleSheet) {
document.createStyleSheet("' . $this->css() . '"); // For Internet Explorer
} else {
jQuery("head").append(\'\');
}
');
if (WT_USE_LIGHTBOX) {
$album = new lightbox_WT_Module();
$album->getPreLoadContent();
}
echo $html;
break;
case 'getDetails':
//$controller = new WT_Controller_Ajax();
//$controller->pageHeader();
Zend_Session::writeClose();
header('Content-Type: text/html; charset=UTF-8');
$pid = WT_Filter::get('pid', WT_REGEX_XREF);
$i = WT_Filter::get('instance');
$tv = new TreeView($i);
$individual = WT_Individual::getInstance($pid);
if ($individual) {
echo $tv->getDetails($individual);
}
break;
case 'getPersons':
//$controller = new WT_Controller_Ajax();
//$controller->pageHeader();
Zend_Session::writeClose();
header('Content-Type: text/html; charset=UTF-8');
$q = WT_Filter::get('q');
$i = WT_Filter::get('instance');
$tv = new TreeView($i);
echo $tv->getPersons($q);
break;
default:
header('HTTP/1.0 404 Not Found');
break;
}
}
public function css() {
return WT_STATIC_URL . WT_MODULES_DIR . $this->getName() . '/css/treeview.css';
}
public function js() {
return WT_STATIC_URL . WT_MODULES_DIR . $this->getName() . '/js/treeview.js';
}
}